-
Notifications
You must be signed in to change notification settings - Fork 141
[jules] Update to use Firebase AI Logic SDK #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit applies the initial changes to migrate from the
firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK).
Key changes include:
1. Updated `ai-catalog/gradle/libs.versions.toml`:
* Bumped `firebaseBom` to `33.14.0`.
* Switched `firebase-vertexai` to `firebase-ai`.
2. Updated `ai-catalog/app/build.gradle.kts`:
* Changed dependency to `libs.firebase.ai`.
3. Updated AI SDK usage in the Imagen sample:
* Modified `ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.kt` to use the new `firebase-ai` SDK, including import changes and updating the ImagenModel initialization to use `Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...)`.
The `core/network/build.gradle.kts` and a central `FirebaseAiDataSource.kt` as seen in the reference PR for `androidify` were not found in this repository's structure. The Imagen-specific AI logic was updated directly in its ViewModel.
Further steps, including updating the README.md, remain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @calren, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
Summary of Changes
Hello! Gemini here, providing a summary of this pull request. This PR aims to initiate the migration from the older firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK) within the ai-catalog project. The changes involve updating dependency declarations in the Gradle files and refactoring the usage of the AI SDK specifically within the Imagen sample's ViewModel to align with the new SDK's API.
Highlights
- SDK Migration: The core purpose of this PR is to begin migrating from the
firebase-vertexaiSDK to the newfirebase-aiSDK. - Dependency Updates: The Firebase Bill of Materials (BOM) version is updated, and the dependency alias and module name for the Firebase AI SDK are changed in the Gradle version catalog (
libs.versions.toml) and the app's build file (build.gradle.kts). - Imagen Sample Update: The Imagen sample's ViewModel (
ImagenViewModel.kt) is updated to use the newfirebase-aiSDK, including changes to imports and the initialization method for theImagenModel.
Changelog
- ai-catalog/app/build.gradle.kts
- Changed the implementation dependency from
libs.firebase.vertexaitolibs.firebase.ai(line 81).
- Changed the implementation dependency from
- ai-catalog/gradle/libs.versions.toml
- Bumped the
firebaseBomversion from33.12.0to33.14.0(line 4). - Renamed the library alias from
firebase-vertexaitofirebase-aiand updated its module definition (line 34).
- Bumped the
- ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.kt
- Updated import statements from
com.google.firebase.vertexai.type.*tocom.google.firebase.ai.type.*(lines 26-28). - Added import for
com.google.firebase.ai.aiandcom.google.firebase.ai.type.GenerativeBackend(lines 30-31). - Refactored the
imagenModelinitialization fromFirebase.vertexAI.imagenModel(...)toFirebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...)(line 45).
- Updated import statements from
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
SDKs change, code must adapt,
From old VertexAI, now wrapped,
Infirebase-ai,
A new way to try,
Dependencies neatly mapped.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request effectively initiates the migration of the Imagen sample within the ai-catalog project from the firebase-vertexai SDK to the new firebase-ai SDK. The changes to the Gradle build files and the ImagenViewModel.kt are clear and directly address the SDK update, particularly the Imagen model initialization and type imports.
I have one point of clarification regarding an import related to a preview API, detailed in the comments. It's also noted from your PR description that further steps, such as updating the README.md, are planned, which is good.
Overall, this is a solid first step in the SDK migration process.
Summary of Findings
- Clarity on
PublicPreviewAPIsource with newfirebase-aiSDK: TheimagenModelis initialized using the newfirebase-aiSDK but is annotated with@OptIn(PublicPreviewAPI::class), wherePublicPreviewAPIis imported from the oldercom.google.firebase.vertexai.typenamespace. Clarification is requested on whether this is the intended source for the annotation with the new SDK, or if an alternative fromfirebase-aishould be used.
Merge Readiness
The pull request makes good progress on the SDK migration. There is one medium-severity point of clarification raised regarding the source of the PublicPreviewAPI annotation in ImagenViewModel.kt. It would be beneficial to address this clarification before merging to ensure alignment with the new SDK's best practices.
As an AI, I am not authorized to approve pull requests. Please ensure this PR is reviewed and approved by the appropriate team members. Once the clarification is addressed, these changes appear to be a positive step forward.
|
|
||
| @OptIn(PublicPreviewAPI::class) | ||
| private val imagenModel = Firebase.vertexAI.imagenModel( | ||
| private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for updating the imagenModel initialization to use the new firebase-ai SDK!
This model (and its initialization here on line 45) is annotated with @OptIn(PublicPreviewAPI::class) (as seen on line 44). I notice the PublicPreviewAPI annotation itself is still imported from com.google.firebase.vertexai.type (line 29).
With the migration to firebase-ai, could you clarify if this is the expected source for the PublicPreviewAPI annotation? It would be helpful to confirm whether the new firebase-ai SDK provides its own version of this annotation for preview features, or if this interdependency with the com.google.firebase.vertexai.type namespace is the intended approach for now. Ensuring all related types and annotations align with the new SDK's structure, where possible, would enhance clarity and future maintainability.
|
closing in favor of #33 |
This commit applies the initial changes to migrate from the firebase-vertexai SDK to the new firebase-ai (Firebase AI Logic SDK).
Key changes include:
ai-catalog/gradle/libs.versions.toml:firebaseBomto33.14.0.firebase-vertexaitofirebase-ai.ai-catalog/app/build.gradle.kts:libs.firebase.ai.ai-catalog/samples/imagen/src/main/java/com/android/ai/samples/imagen/ImagenViewModel.ktto use the newfirebase-aiSDK, including import changes and updating the ImagenModel initialization to useFirebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel(...).The
core/network/build.gradle.ktsand a centralFirebaseAiDataSource.ktas seen in the reference PR forandroidifywere not found in this repository's structure. The Imagen-specific AI logic was updated directly in its ViewModel.Further steps, including updating the README.md, remain.